//
//  HHPHomeViewModel.m
//  HHPLiveVideo
//
//  Created by 韩红坡 on 2017/4/19.
//  Copyright © 2017年 韩红坡. All rights reserved.
//

#import "HHPHomeViewModel.h"

@interface HHPHomeViewModel ()

@property (nonatomic, strong) HHPHomeService *service;

@end

@implementation HHPHomeViewModel
#pragma mark - public methods
- (void)fetchADDataWithCompletionBlock:(void (^)(BOOL))completionBlock
{
    HHPHTTPRequest *request = [self.service fetchADData];
    
    [request startWithSuccess:^(HHPHTTPRequest *request) {
        self.adArray = request.data;
        
        completionBlock(YES);
    } error:^(HHPHTTPRequest *request) {
        completionBlock(NO);
    }];
}

#pragma mark - getter and setter
- (HHPHomeService *)service
{
    if (!_service) {
        _service = [[HHPHomeService alloc] init];
    }
    
    return _service;
}

- (NSMutableArray<HHPADModel *> *)adArray
{
    if (!_adArray) {
        _adArray = [NSMutableArray array];
    }
    
    return _adArray;
}

@end
